﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Principal;
using MiserBlogData.Entities;

namespace MiserBlogMVC.Models
{
    public abstract class A_BaseIdentity : IIdentity
    {
        public bool IsAuthenticated { get; protected set; }
        public string Name { get; protected set; }
        public A_Person Person { get; protected set; }
        public PersonRole Role { get; set; }

        public A_BaseIdentity()
        {
            
        }

        protected virtual void Auth()
        {
            Person = A_Person.CreateWithCookie();
            if (Person.Role >= (short)Role)
            {
                Name = Person.Name;
                IsAuthenticated = true;
                return;
            }
            IsAuthenticated = false;
            Name = string.Empty;
        }

        public string AuthenticationType
        {
            get { throw new NotImplementedException(); }
        }
    }
}